﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Globalization;

namespace ComboBoxExample
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();

            SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

            IList<string> provinces = new[] {
                                          "British Columbia", "Alberta", "Saskatchewan", "Manitoba", "Ontario", "Quebec",
                                          "Newfoundland and Labrador", "Prince Edward Island", "New Brunswick",
                                          "Nova Scotia", "Nunavut", "Yukon", "Northwest Territories"
                                      };

            IList<Province> Provinces = new List<Province>();
            Provinces.Add(new Province("British Columbia", "BC", new DateTime(1871, 7, 20)));
            Provinces.Add(new Province("Alberta", "AB", new DateTime(1905, 9, 1)));
            Provinces.Add(new Province("Saskatchewan", "SK", new DateTime(1905, 9, 1)));
            Provinces.Add(new Province("Manitoba", "MB", new DateTime(1870, 7, 15)));
            Provinces.Add(new Province("Ontario", "ON", new DateTime(1867, 7, 1)));
            Provinces.Add(new Province("Quebec", "QC", new DateTime(1867, 7, 1)));
            Provinces.Add(new Province("Newfoundland", "NL", new DateTime(1949, 3, 31)));
            Provinces.Add(new Province("Prince Edward Island", "PE", new DateTime(1873, 7, 1)));
            Provinces.Add(new Province("New Brunswick", "NB", new DateTime(1867, 7, 1)));
            Provinces.Add(new Province("Nova Scotia", "NS", new DateTime(1867, 7, 1)));
            Provinces.Add(new Province("Nunavut", "NU", new DateTime(1999, 4, 1)));
            Provinces.Add(new Province("Yukon", "YT", new DateTime(1898, 6, 13)));
            Provinces.Add(new Province("Northwest Territories", "NT", new DateTime(1870, 7, 15)));
            //this.cboProvinces4.ItemsSource = Provinces;
            //this.cboProvinces4.SelectedIndex = 0;
        }

        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            object selectedItem = ((ComboBox)sender).SelectedItem;
            //this.txtSelection.Text = (selectedItem == null)
            //                            ? string.Empty
            //                            : ((Province)selectedItem).Description;
        }
    }

    public class Province
    {
        public Province(string fullName, string abbreviation, DateTime dateOfConfederation)
        {
            FullName = fullName;
            Abbreviation = abbreviation;
            DateOfConfederation = dateOfConfederation;
        }

        public string FullName { get; set; }
        public string Abbreviation { get; set; }
        public DateTime DateOfConfederation { get; set; }

        public string Description
        {
            get
            {
                return string.Format("{0} (DOC: {1})",
                  FullName, DateOfConfederation.ToShortDateString());
            }
        }
    }
}